package com.lemeng.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("login")
public class LoginController {

    @RequestMapping("username")
    public Map<String,Object> username(){
        HashMap hashMap = new HashMap();
        String username = SecurityContextHolder.getContext().getAuthentication().getName();
        hashMap.put("username",username);
        return hashMap;
    }
}
